| Total Complexity | 2 | 
| Total Lines | 31 | 
| Duplicated Lines | 0 % | 
| Changes | 0 | ||
| 1 | import { Inject } from '@nestjs/common'; | 
            ||
| 7 | |||
| 8 | @QueryHandler(GetContactsQuery)  | 
            ||
| 9 | export class GetContactsQueryHandler { | 
            ||
| 10 | constructor(  | 
            ||
| 11 |     @Inject('IContactRepository') | 
            ||
| 12 | private readonly contactRepository: IContactRepository  | 
            ||
| 13 |   ) {} | 
            ||
| 14 | |||
| 15 | public async execute(  | 
            ||
| 16 | query: GetContactsQuery  | 
            ||
| 17 |   ): Promise<Pagination<ContactView>> { | 
            ||
| 18 | const contactsView: ContactView[] = [];  | 
            ||
| 19 | const [contacts, total] = await this.contactRepository.findContacts(  | 
            ||
| 20 | query.page  | 
            ||
| 21 | );  | 
            ||
| 22 | |||
| 23 |     for (const contact of contacts) { | 
            ||
| 24 | contactsView.push(  | 
            ||
| 25 | new ContactView(  | 
            ||
| 26 | contact.getId(),  | 
            ||
| 27 | contact.getFirstName(),  | 
            ||
| 28 | contact.getLastName(),  | 
            ||
| 29 | contact.getCompany(),  | 
            ||
| 30 | contact.getEmail(),  | 
            ||
| 31 | contact.getPhoneNumber(),  | 
            ||
| 32 | contact.getNotes()  | 
            ||
| 33 | )  | 
            ||
| 34 | );  | 
            ||
| 35 | }  | 
            ||
| 36 | |||
| 37 | return new Pagination<ContactView>(contactsView, total);  | 
            ||
| 38 | }  | 
            ||
| 40 |